<!DOCTYPE html>
<html>

<head>
    <title>
        <%= typeof title !=='undefined' ? title : '爬虫后台' %>
    </title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <style>
        .layout-navbar {
            background: #333;
            color: #fff;
            padding: 1rem 1rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-sizing: border-box;
        }

        .layout-navbar .logo {
            font-size: 15px;
            font-weight: bold;
        }

        .layout-navbar nav a {
            color: #fff;
            text-decoration: none;
            margin-left: 1.5rem;
            transition: color 0.2s;
        }

        .layout-navbar nav a:hover {
            color: #ffd700;
        }

        h1 {
            color: #333;
            margin-bottom: 0.5em;
        }

        p {
            color: #666;
            font-size: 1.1em;
        }

        .layout {
            height: auto;
            padding: 4px;
        }

        .layout-container {
            height: 100%;
            width: 100%;
            margin: 5px auto 0 auto;
            background: #fff;
            border-radius: 5px;
            border: 1px solid #dcdfe6;
            padding: 1.5rem 1rem 1rem 1rem;
            flex: 1 0 auto;
            box-sizing: border-box;
        }

        .layout-footer {
            position: fixed;
            bottom: 0;
            width: 100%;
            flex-shrink: 0;
            text-align: center;
            padding: 1em 0 0.5em 0;
            font-size: 0.95em;
            color: #aaa;
            background: transparent;
            box-sizing: border-box;
        }
    </style>
    <%- style %>
</head>

<body>
    <div class="layout-navbar">
        <div class="logo">
            爬虫后台
        </div>
        <nav>
            <a href="/">首页</a>
            <a href="/users/list_page">用户</a>
        </nav>
    </div>
    <div class="layout">
        <div class="layout-container">
            <%- body %> <!-- 这里插入页面内容 -->
        </div>
    </div>
    <footer class="layout-footer">
        &copy; <%= new Date().getFullYear() %>
            <%= typeof title !=='undefined' ? title : '爬虫' %> | Powered by 北京医欣
    </footer>

    <script>
        // layout-container 高度计算, 等于 页面高度 - 导航栏高度
        const navbar = document.querySelector('.layout-navbar');
        const footer = document.querySelector(".layout-footer")
        const pageHeight = document.body.clientHeight;
        const navbarHeight = navbar.offsetHeight;
        const footerheight = footer.offsetHeight;
        const layoutContainer = document.querySelector('.layout-container');
        layoutContainer.style.height = `${pageHeight - navbarHeight - footerheight}px`;
    </script>

    <%- script %>
</body>

</html>